import api from '../http'
import { FourmDataModel, SetPostStatusModel, AddCriticizeModel } from './Model'

//添加帖子
export const apiAdd = (data: FourmDataModel) => {
  return api({
    url: '/forum/add',
    method: 'POST',
    data,
  })
}

//获取帖子列表
export const apiGetForumList = (params: any) => {
  return api({
    url: '/forum/getList',
    method: 'GET',
    params,
  })
}

//获取帖子详情
export const apiGetForumDetails = (postId: number) => {
  return api({
    url: `/forum/details/${postId}`,
    method: 'GET',
  })
}

//修改帖子
export const apiSetPostStatus = (params: SetPostStatusModel) => {
  return api({
    url: `/forum/editStatus`,
    method: 'POST',
    params,
  })
}

//添加评论
export const apiAddCriticize = (data: AddCriticizeModel) => {
  return api({
    url: `/criticize/add`,
    method: 'POST',
    data,
  })
}

//获取评论列表
export const apiGetComments = (params: any) => {
  return api({
    url: `/criticize/list`,
    method: 'GET',
    params,
  })
}

//删除评论
export const apiDeleteComment = (criticizeId: number) => {
  return api({
    url: `/criticize/delete/${criticizeId}`,
    method: 'DELETE',
  })
}

//点赞或者取消点赞
export const apiDropLike = (params: any) => {
  return api({
    url: `/postLike/dropLike`,
    method: 'GET',
    params,
  })
}

//删除帖子
export const apiDeletePost = (postId: number) => {
  return api({
    url: `/forum/delete/${postId}`,
    method: 'DELETE',
  })
}
